package com.schoolvisitors.vo;


import com.schoolvisitors.entity.Instrument;
import com.schoolvisitors.entity.InstrumentSubType;
import lombok.Data;

@Data
public class ManageInstrumentVo {
    private Long id;
    private Long roomId;
    private String roomName; // 可选：若需要显示房间名
    private String name;
    private Long type;
    private Long subType;
    private Boolean available;
    private Long pointsCost;
    private String imgName;

//    private String base64Image;

    public static ManageInstrumentVo toVo(Instrument instrument) {
        ManageInstrumentVo vo = new ManageInstrumentVo();
        vo.setId(instrument.getId());
        vo.setRoomId(instrument.getRoom().getId());
        vo.setRoomName(instrument.getRoom().getSubType()); // 前提是已加载房间名
        vo.setName(instrument.getName());
        vo.setType(instrument.getType());
        vo.setSubType(instrument.getSubType().getId());
        vo.setAvailable(instrument.getAvailable());
        vo.setPointsCost(instrument.getPointsCost());
        vo.setImgName(instrument.getImgName());

//        if (instrument.getImg() != null) {
//            String base64 = java.util.Base64.getEncoder().encodeToString(instrument.getImg());
//            vo.setBase64Image("data:image/png;base64," + base64); // 假设图片为 PNG
//        }

        return vo;
    }
}
